#coding=UTF-8
import requests
import json

# 引入自定义的keystone模块
import keystone
keystone_s=keystone.getToken()

#nova(compute)端点地址：
glance_url="http://192.168.100.10:9292/v2/images/"
#定义请求头
headers={
    "X-Auth-Token":keystone_s['token'],
    "Content-Type":"application/octet-stream"
}
image_id="06e9c148-df73-4f01-b0c7-258ead33cc9d"
#发送请求
req=requests.put(glance_url+image_id+'/file',headers=headers,data=open(r"F:\my_p\openstack-rustful-api\rustful-api\cirros-0.3.4-x86_64-disk.img",'rb').read())
if (req.status_code)==204:
    print ("上传成功")
else:
    print (req.status_code)